<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>cssmoban</title>
    <!-- Bootstrap Styles-->
    <link href="../assets/css/bootstrap.css" rel="stylesheet" />
    <!-- FontAwesome Styles-->
    <link href="../assets/css/font-awesome.css" rel="stylesheet" />
    <!-- Morris Chart Styles-->

    <!-- Custom Styles-->
    <link href="../assets/css/custom-styles.css" rel="stylesheet" />
    <!-- Google Fonts-->
    <link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
    <!-- TABLE STYLES-->
    <link href="../assets/js/dataTables/dataTables.bootstrap.css" rel="stylesheet" />
    <link rel="stylesheet" href="../layui/css/layui.css" media="all">
    <script src="../layui/layui.js" charset="utf-8"></script>

</head>
<body>
<div id="wrapper">



    <nav class="navbar navbar-default top-navbar" role="navigation">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#"><strong>后台管理系统</strong></a>

        </div>

        <ul class="nav navbar-top-links navbar-right">
            <li class="dropdown">
                <a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false">
                    <i class="fa fa-user fa-fw"></i> <span id="username"></span>
                </a>
                <ul class="dropdown-menu dropdown-user">
                    <li class="divider"></li>
                    <li><a href="../logOut"><i class="fa fa-sign-out fa-fw"></i>注销</a>
                    </li>
                </ul>
            </li>
        </ul>
    </nav>
    <!--/. NAV TOP  -->
    <nav class="navbar-default navbar-side" role="navigation">
        <div class="sidebar-collapse">
            <ul class="nav" id="main-menu">

                <li>
                    <a href="../knowledge/admin.html"><i class="fa fa-dashboard"></i>主页</a>
                </li>
                <li>
                    <a href="../folk/admin"><i class="fa fa-bar-chart-o"></i> 民间医药数据库</a>
                </li>
                <li>
                    <a href="#"><i class="fa fa-qrcode"></i>传统知识数据库<span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li>
                            <a href="../searchTcm">查询中医药知识</a>
                        </li>
                        <li>
                            <a href="../addTcm">添加中医药知识</a>
                        </li>
                    </ul>
                </li>
                <li >
                    <a href="../user/userManage"><i class="fa fa-bar-chart-o"></i> 用户管理</a>
                </li>
            </ul>

        </div>

    </nav>
    <!-- /. NAV SIDE  -->
    <div id="page-wrapper" >
        <h1 style="padding-top: 20px;padding-left: 0">
            <div class="layui-form input-group">
                <div class="layui-form-item">
                    <div class="layui-input-block" style="margin-left: 60px;">
                        <span style="font-size: 16px">搜索项目</span>
                        <input type="radio" name="sex"  value="1" title="持有人姓名" checked="checked" lay-filter="byKeeper">
                        <input type="radio" name="sex"  value="0" title="验方名称" lay-filter="byMedic">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block" style="margin-left: 60px;">
                        <div class="input-group">
                            <input type="text" class="form-control"/>
                            <span class="input-group-addon" id='formSearch' style="width: 100px;"><a href="#"><i class="glyphicon glyphicon-search"><span>搜索</span></i></a></span>
                        </div>
                    </div>
                </div>
            </div>
        </h1>




        <div id="page-inner">

            <div class="row">
                <div class="col-md-12">

                    <!-- Advanced Tables -->
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <div class="table-responsive">
                                <table id="demo" lay-filter="test"></table>
                            </div>

                        </div>
                    </div>
                    <!--End Advanced Tables -->
                </div>
            </div>
        </div>
    </div>
</div>
    </div>
</div>
</body>
        <script>
            var urlTmp = '/folk/selectByHolderName/?name=';
            layui.use('table', function(){
                var table = layui.table;
                var xhr = new XMLHttpRequest();
                xhr.onreadystatechange=function () {
                    if (xhr.readyState!=4||xhr.status!=200){
                        return;
                    }
                    else

                    $("#username").text(xhr.responseText)
                }
                xhr.open('GET', '../name');
                xhr.send();
               window.renderTable=function (url) {
                   table.render({
                       elem: '#demo'
                       ,url: url
                       //../folk/listMedicine
                       ,page: true
                       ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
                       ,cols: [[
                           {field:'id', width:80, title: 'ID' }
                           ,{field:'name', width:80, title: '持有人姓名'}
                           ,{field:'sex', width:80, title: '性别' }
                           ,{field:'city', width:80, title: '城市' }
                           ,{field:'prescriptionname', title: '验方名称' }
                           ,{field:'medicinetype', width:80, title: '类型'}
                           ,{field:'xyk',  title: '西医科别' }
                           ,{field:'xykjb', title: '西医病名' }
                           ,{field:'zyk', title: '中医科别' }
                           ,{field:'zyjb', title: '中医病名' }
                           ,{field:'checkflag', width:80, title: '审核' }
                           ,{ title: '操作',align: 'center',templet:'#barTool'}
                       ]]
                       ,limit: 20
                   });
               }
               renderTable("../folk/listMedicine");
            });
        </script>
<script type="text/html" id="barTool">
    <a lay-event="detail">
        <button class="layui-btn layui-btn-sm" lay-event="showDetail">
            <i class="layui-icon">
                &#xe60a;
            </i>详情</button>
    </a>

</script>
<script >
    layui.use(['table','form'],function () {
        var table  = layui.table;
        var form =layui.form;
        //监听表格复选框选择
        table.on('tool(test)',function (obj) {
            var  data = obj.data;
            window.form=layui.form;
            if (obj.event === 'detail') {
                layer.open({
                    type: 0,
                    //layer提供了5种层类型。可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）
                    title: "验方详情",
                    skin: "layui-layer-rim",
                    area: ['900px', '650px'],
                    content: $("<div  class=\"layui-row\" id=\"test\" lay-event=\"detail\">" +
                        "      <form class=\"layui-form layui-form-pane\" lay-filter=\"formFilter\" id=\"editTcm\"  style=\"width: auto\">" +
                        "        <div class=\"layui-form-item\">" +
                        "            <label class=\"layui-form-label\">持有者名称</label>" +
                        "            <div class=\"layui-input-inline\">" +
                        "                <input type=\"text\" disabled=\"\" name=\"name\" lay-verify=\"title\" autocomplete=\"off\" placeholder=\"请输入标题\" class=\"layui-input\">" +
                        "            </div>" +
                        "        </div>" +
                        "        <div class=\"layui-form-item\">" +
                        "            <label class=\"layui-form-label\">性别</label>" +
                        "            <div class=\"layui-input-block\">" +
                        "                <input type=\"radio\"  name=\"sex\" value=\"男\" title=\"男\" checked=\"\">" +
                        "                <input type=\"radio\"  name=\"sex\" value=\"女\" title=\"女\" >" +
                        "" +
                        "            </div>" +
                        "        </div>" +
                        "        <div class=\"layui-inline\">" +
                        "            <label class=\"layui-form-label\">出生日期</label>" +
                        "            <div class=\"layui-input-inline\">" +
                        "                <input type=\"text\" disabled=\"\" name=\"birth\"  lay-verify=\"date\" placeholder=\"yyyy-MM-dd\" autocomplete=\"off\" class=\"layui-input\">" +
                        "            </div>" +
                        "        </div>" +
                        "        <div class=\"layui-form-item\">" +
                        "            <label class=\"layui-form-label\">居住地址</label>" +
                        "            <div class=\"layui-input-block\">" +
                        "                <input type=\"text\" disabled=\"\" name=\"city\" lay-verify=\"title\" autocomplete=\"off\" placeholder=\"\" class=\"layui-input\">" +
                        "            </div>" +
                        "        </div>" +
                        "        <div class=\"layui-form-item\">" +
                        "            <div class=\"layui-inline\">" +
                        "                <label class=\"layui-form-label\">固定电话</label>" +
                        "                <div class=\"layui-input-inline\">" +
                        "                    <input type=\"tel\" disabled=\"\" name=\"telephone\" lay-verify=\"required|phone\" autocomplete=\"off\" class=\"layui-input\">" +
                        "                </div>" +
                        "            </div>" +
                        "            <div class=\"layui-inline\">" +
                        "                <label class=\"layui-form-label\">手机号码</label>" +
                        "                <div class=\"layui-input-inline\">" +
                        "                    <input type=\"text\" disabled=\"\" name=\"phone\" lay-verify=\"phone\" autocomplete=\"off\" class=\"layui-input\">" +
                        "                </div>" +
                        "            </div>" +
                        "        </div>" +
                        "        <div class=\"layui-form-item\">" +
                        "            <label class=\"layui-form-label\">通讯地址</label>" +
                        "            <div class=\"layui-input-block\">" +
                        "                <input type=\"text\" disabled=\"\" name=\"postaddress\" lay-verify=\"postaddress\" autocomplete=\"off\" placeholder=\"\" class=\"layui-input\">" +
                        "            </div>" +
                        "        </div>" +
                        "        <div class=\"layui-form-item\">" +
                        "            <label class=\"layui-form-label\">从业地点</label>" +
                        "            <div class=\"layui-input-block\">" +
                        "                <input type=\"text\" disabled=\"\" name=\"workaddress\" lay-verify=\"workaddress\" autocomplete=\"off\" placeholder=\"\" class=\"layui-input\">" +
                        "            </div>" +
                        "        </div>" +
                        "        <div class=\"layui-form-item\">" +
                        "            <label class=\"layui-form-label\">从业类别</label>" +
                        "            <div class=\"layui-input-inline\">" +
                        "                <input type=\"text\" disabled=\"\" name=\"post\" lay-verify=\"post\" autocomplete=\"off\" placeholder=\"\" class=\"layui-input\">" +
                        "            </div>" +
                        "        </div>" +
                        "        <div class=\"layui-form-item\">" +
                        "            <label class=\"layui-form-label\">教育背景</label>" +
                        "            <div class=\"layui-input-block\">" +
                        "                <input type=\"text\" disabled=\"\" name=\"resume\" lay-verify=\"resume\" autocomplete=\"off\" placeholder=\"\" class=\"layui-input\">" +
                        "            </div>" +
                        "        </div>" +
                        "        <div class=\"layui-form-item\">" +
                        "            <label class=\"layui-form-label\">专长由来</label>" +
                        "            <div class=\"layui-input-inline\">" +
                        "                <input type=\"text\" disabled=\"\" name=\"source\" lay-verify=\"post\" autocomplete=\"off\" placeholder=\"\" class=\"layui-input\">" +
                        "            </div>" +
                        "        </div>" +
                        "" +
                        "        <div class=\"layui-form-item layui-form-text\">" +
                        "            <label class=\"layui-form-label\">专长简介</label>" +
                        "            <div class=\"layui-input-block\">" +
                        "                <div disabled=\"\" name=\"introduce\" id=\"introduction\" placeholder=\"\" class=\"layui-textarea\"></div>" +
                        "            </div>" +
                        "        </div>" +
                        "        <div class=\"layui-form-item\">" +
                        "            <label class=\"layui-form-label\">验方-专长名</label>" +
                        "            <div class=\"layui-input-inline\">" +
                        "                <input type=\"text\" disabled=\"\" name=\"prescriptionname\" lay-verify=\"post\" autocomplete=\"off\" placeholder=\"\" class=\"layui-input\">" +
                        "            </div>" +
                        "        </div>" +
                        "        <div class=\"layui-form-item\">" +
                        "            <label class=\"layui-form-label\">类别</label>" +
                        "            <div class=\"layui-input-inline\">" +
                        "                <input type=\"text\" disabled=\"\" name=\"category\" lay-verify=\"post\" autocomplete=\"off\" placeholder=\"\" class=\"layui-input\">" +
                        "            </div>" +
                        "        </div>" +
                        "        <div class=\"layui-form-item\">" +
                        "            <label class=\"layui-form-label\">西医科</label>" +
                        "            <div class=\"layui-input-inline\">" +
                        "                <input type=\"text\" disabled=\"\" name=\"xyk\" lay-verify=\"resume\" autocomplete=\"off\" placeholder=\"\" class=\"layui-input\">" +
                        "            </div>" +
                        "        </div>" +
                        "        <div class=\"layui-form-item\">" +
                        "            <label class=\"layui-form-label\">西医科疾病</label>" +
                        "            <div class=\"layui-input-inline\">" +
                        "                <input type=\"text\" disabled=\"\" name=\"xykjb\" lay-verify=\"resume\" autocomplete=\"off\" placeholder=\"\" class=\"layui-input\">" +
                        "            </div>" +
                        "        </div>" +
                        "        <div class=\"layui-form-item\">" +
                        "            <label class=\"layui-form-label\">中医科</label>" +
                        "            <div class=\"layui-input-inline\">" +
                        "                <input type=\"text\" disabled=\"\" name=\"zyk\" lay-verify=\"resume\" autocomplete=\"off\" placeholder=\"\" class=\"layui-input\">" +
                        "            </div>" +
                        "        </div>" +
                        "        <div class=\"layui-form-item\">" +
                        "            <label class=\"layui-form-label\">中医科疾病</label>" +
                        "            <div class=\"layui-input-inline\">" +
                        "                <input type=\"text\" disabled=\"\" name=\"zyjb\" lay-verify=\"resume\" autocomplete=\"off\" placeholder=\"\" class=\"layui-input\">" +
                        "            </div>" +
                        "        </div>" +
                        // "        <div class=\"layui-form-item\">" +
                        // "            <label class=\"layui-form-label\">验方剂型</label>" +
                        // "            <div class=\"layui-input-inline\">" +
                        // "                <input type=\"text\" disabled=\"\" name=\"yfjx\" lay-verify=\"resume\" autocomplete=\"off\" placeholder=\"\" class=\"layui-input\">" +
                        // "            </div>" +
                        // "        </div>" +
                        "        <div class=\"layui-form-item\">" +
                        "            <label class=\"layui-form-label\">验方剂型</label>" +
                        "            <div class=\"layui-input-inline\">" +
                        "                <input type=\"text\" disabled=\"\" name=\"yfjx\" lay-verify=\"resume\" autocomplete=\"off\" placeholder=\"\" class=\"layui-input\">" +
                        "            </div>" +
                        "        </div>" +
                        "        <div class=\"layui-form-item\">" +
                        "            <label class=\"layui-form-label\">类别-特色诊疗-验方</label>" +
                        "            <div class=\"layui-input-inline\">" +
                        "                <input type=\"text\" disabled=\"\" name=\"medicinetype\" lay-verify=\"resume\" autocomplete=\"off\" placeholder=\"\" class=\"layui-input\">" +
                        "            </div>" +
                        "        </div>" +
                        "        <div class=\"layui-form-item layui-form-text\">" +
                        "            <label class=\"layui-form-label\">处方组成</label>" +
                        "            <div class=\"layui-input-block\">" +
                        "                <textarea disabled=\"\" name=\"prescription\" placeholder=\"\" class=\"layui-textarea\"></textarea>" +
                        "            </div>" +
                        "        </div>" +
                        "        <div class=\"layui-form-item layui-form-text\">" +
                        "            <label class=\"layui-form-label\">适应症</label>" +
                        "            <div class=\"layui-input-block\">" +
                        "                <textarea disabled=\"\" name=\"treatfit\" placeholder=\"\" class=\"layui-textarea\"></textarea>" +
                        "            </div>" +
                        "        </div>" +
                        "        <div class=\"layui-form-item layui-form-text\">" +
                        "            <label class=\"layui-form-label\">技巧</label>" +
                        "            <div class=\"layui-input-block\">" +
                        "                <textarea disabled=\"\" name=\"skill\" placeholder=\"\" class=\"layui-textarea\"></textarea>" +
                        "            </div>" +
                        "        </div>" +
                        "    </form>" +
                        "    </div>").html(),
                    success:function () {
                        setFormValue(data);
                    }
                })

            }
        })

        form.on('radio(byKeeper)', function (obj) {
            urlTmp = '/folk/selectByHolderName/?name='

        })
        form.on('radio(byMedic)',function (obj) {
            urlTmp = '/folk/selectByPrescriptionName/?prescriptionname='
        })
        $('#formSearch').click(function (e) {
            renderTable(urlTmp+$('.form-control').val())
        })
    })

</script>
<script>
    function setFormValue(data) {
        $('input[type=radio][name=sex][value='+data.sex+']').attr('checked', true)
        var html = data.introduce.replace('&lt;', "<").replace('&gt;', ">");
        $('#introduction').html(html);
        form.val("formFilter", {
            "name": data.name,
            "birth":data.birth,
            "city":data.province+"省"+data.city+"市"+data.town,
            "telephone": data.telephone,
            "phone": data.phone,
            "postaddress": data.postaddress,
            "workaddress": data.workaddress,
            "post":data.post,
            "resume":data.resume,
            "source":data.source,
            "prescriptionname": data.prescriptionname,
            "category":data.category,
            "prescription": data.prescription,
            "treatfit":data.treatfit,
            "skill":data.skill,
            "xyk":data.xyk,
            "xykjb": data.xykjb,
            "zyk": data.zyk,
            "zyjb":data.zyjb,
            "yfjx":data.yfjx,
            "medicinetype":data.medicinetype
        });
    }
</script>

        <script src="../assets/js/jquery-1.10.2.js"></script>
        <!-- Bootstrap Js -->
        <script src="../assets/js/bootstrap.min.js"></script>
        <!-- Metis Menu Js -->
        <script src="../assets/js/jquery.metisMenu.js"></script>
        <!-- DATA TABLE SCRIPTS -->
        <script src="../assets/js/dataTables/jquery.dataTables.js"></script>
        <script src="../assets/js/dataTables/dataTables.bootstrap.js"></script>
        <!-- Custom Js -->
        <script src="../assets/js/custom-scripts.js"></script>
</html>

